package basicTypes;

import java.sql.Date;

public class RAReserve implements Comparable {
	private int userid;
	private int resourceId;
	private Date dia;
	private String hora;
	
	public RAReserve(int uid,int rid,Date dia,String hora){
		this.userid=uid;
		this.resourceId=rid;
		this.dia=dia;
		this.hora=hora;		
	}

	public int getUserid() {
		return userid;
	}

	public void setUserid(int userid) {
		this.userid = userid;
	}

	public int getResourceId() {
		return resourceId;
	}

	public void setResourceId(int resourceId) {
		this.resourceId = resourceId;
	}

	public Date getDia() {
		return dia;
	}

	public void setDia(Date dia) {
		this.dia = dia;
	}

	public String getHora() {
		return hora;
	}
	public boolean isNull(){
		return (this.getUserid()==0&&this.getResourceId()==0&&this.getDia()==null&&this.getHora()=="");
	}

	public void setHora(String hora) {
		this.hora = hora;
	}	
	
	public String toString() {
		return "Reserve: "+userid+"->"+resourceId+" at "+hora+" on "+dia;
	}
	
	@Override
	public int compareTo(Object arg0) {
		if (this.getClass().toString().compareTo(arg0.getClass().toString())==0) {
			return (this.getResourceId()==((RAReserve)arg0).getResourceId() 
			&&
				this.getUserid()==((RAReserve)arg0).getUserid() 
				&&
				this.getDia().compareTo(((RAReserve)arg0).getDia())==0
				&&
				this.getHora().compareTo(((RAReserve)arg0).getHora())==0
				? 0 : 1);
		}
		else return -1;
	}
	
}
